<%@ page language="java" contentType="text/html;charset=UTF-8" pageEncoding="UTF-8" %>
<%@ page import="com.scalar.chiptrack.utils.ConfigManager,
				 com.scalar.chiptrack.users.Functionality,
				 com.scalar.chiptrack.commons.Constants"%>

<%@ taglib uri="/WEB-INF/struts-bean.tld" prefix="bean" %>
<%@ taglib uri="/WEB-INF/struts-html.tld" prefix="html" %>
<%@ taglib uri="/WEB-INF/struts-logic.tld" prefix="logic" %>
<%@ taglib uri="/WEB-INF/struts-nested.tld" prefix="nested" %> 
<%@ taglib uri="/WEB-INF/chiptrack-tags.tld" prefix="chiptrack" %>

<chiptrack:checkLogon sourcePage="/vendor.do"/>

<%String chipTracContext = "/" + ConfigManager.getChipTracContext();%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<%
 
  java.util.ArrayList list = new java.util.ArrayList();
  list.add(new org.apache.struts.util.LabelValueBean("As Needed", "As Needed"));
  list.add(new org.apache.struts.util.LabelValueBean("Weekly", "Weekly"));
  list.add(new org.apache.struts.util.LabelValueBean("Monthly", "Monthly"));
  list.add(new org.apache.struts.util.LabelValueBean("Quarterly", "Quarterly"));
  pageContext.setAttribute("poFrequencies", list);
  
   
%>

      
<HTML><HEAD><TITLE>Scalarsoft - ChipTrac</TITLE>
<META http-equiv=Content-Type content="text/html; charset=UTF-8">
<LINK href="<%=chipTracContext%>/jsp/includes/stylesheets/scalarsoft.css" type=text/css rel=stylesheet>

<META content="Microsoft FrontPage 5.0" name=GENERATOR></HEAD>
<SCRIPT language="JavaScript" src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<BODY bgColor="#ffffff" leftMargin=0 topMargin=0 marginheight="0" marginwidth="0">

<SCRIPT language="JavaScript">
if (document.layers)
	window.setResizable(false);
	var c = 0;
	function addTextArea() {
		var count=document.vendorForm.counter.value;
		var htmltext = '<tr><table border="0" width="100%" height="195"><tr><td colspan=5><img src="images/spacer.gif" height=10></td></tr><tr><td width="20%" height="23"><font class="NArialL" >Contact Person</font></td><td width="20%" height="23"><input type="text" name="T15" size="20" class="txfield"></td><td width="8%" height="23"></td><td width="20%" height="23"><font class="NArialL" >Email</font></td><td width="32%" height="23"><input type="text" name="T19" size="20" class="txfield"></td></tr><tr><td width="20%" height="23"><font class="NArialL" >Phone</font></td><td width="20%" height="23"><input type="text" name="T15" size="20" class="txfield"></td><td width="8%" height="23"></td><td width="20%" height="23"><font class="NArialL" >Fax</font></td><td width="32%" height="23"><input type="text" name="Email" size="20" class="txfield"></td></tr><tr><td width="20%" height="23"><font class="NArialL" >Address 1</font></td><td width="20%" height="23"><input type="text" name="T15" size="20" class="txfield"></td><td width="8%" height="23"></td><td width="20%" height="23"><font class="NArialL" >Address 2</font></td><td width="32%" height="23"><input type="text" name="T19" size="20" class="txfield"></td></tr><tr><td width="20%" height="23"><font class="NArialL" >City</font></td><td width="20%" height="23"><input type="text" name="T15" size="20" class="txfield"></td><td width="8%" height="23"></td><td width="20%" height="23"><font class="NArialL" >State</font></td><td width="32%" height="23"><input type="text" name="T19" size="20" class="txfield"></td></tr><tr><td width="20%" height="23"><font class="NArialL" >Zip</font></td><td width="20%" height="23"><input type="text" name="T15" size="20" class="txfield"></td><td width="8%" height="23"></td><td width="20%" height="23"><font class="NArialL" >Country</font></td><td width="32%" height="23"><input type="text" name="T19" size="20" class="txfield"></td></tr><tr><td colspan=5><table cellspacing=0 cellpadding=0 border=1 width="88%"><tr colspan=3 class="NArialL">Services Provided at Vendor Location&nbsp;-'+count+':</td></tr><tr><td class="NArialL"><input type="checkbox" name="C1" value="ON">Fab</td><td class="NArialL"><input type="checkbox" name="C1" value="ON">Wafer Store</td><td class="NArialL"><input type="checkbox" name="C1" value="ON">Sort</td><td class="NArialL"><input type="checkbox" name="C1" value="ON">Die Bank</td><td class="NArialL"><input type="checkbox" name="C1" value="ON">Assembly</td></tr><tr><td class="NArialL"><input type="checkbox" name="C1" value="ON">Test</td><td class="NArialL"><input type="checkbox" name="C1" value="ON">Class Store</td><td class="NArialL"><input type="checkbox" name="C1" value="ON">Mark & Pack</td><td class="NArialL" colspan=2><input type="checkbox" name="C1" value="ON">Finished Goods</td></table></td></tr></table>'
		/*
<tr><td height="23" colspan=5 bgcolor="#DEE1E2"><font class="NArialL" >Vendor Location&nbsp;-'+count+':</font>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type="checkbox" name="C1" value="OFF"><font class="NArialL" >Remove</font></td></tr>
		*/
		var shippingno=parseInt(count)+1;
		vendorForm.counter.value=shippingno;
		var pa=document.getElementById("font1");
		pa.insertAdjacentHTML('BeforeEnd',htmltext);
	}

/*	function checkLocations(theForm,val)
	{
		for ( var j=0; j< val; j++ )
		{
			var isChecked = 1;
			var temp = "vendor.locationsList["+j+"].locationAddress.selectedLocationTypes";
			var x = eval(theForm[temp]);
			var z = eval(theForm["vendor.locationsList["+j+"].remove"]);

			for ( var i=0; i< x.length; i++ )
			{
				if ( x[i].checked )
				{
					isChecked = 0;
					z.checked = '';
					break;
				}
			}
			if(isChecked == 1)
				z.checked = true;
		}
	}
	*/

	//This function is modified by Bhaskar on 25 November
    function IsValidNetTerms()
    {
		var errors = '';
		var pa=document.getElementById("errors");
		pa.innerHTML = errors;
		if(!isInteger(document.vendorForm['vendor.netTerms'].value))
		{
			errors = 'Please enter a valid net terms(only integers)';
			pa.innerHTML = errors;
			return false;
		}
		return true;
    }

	function IsValidPayByDate()
	{
		var errors = '';
		var pa=document.getElementById("errors");
		pa.innerHTML = errors;
		if(!isInteger(document.vendorForm['vendor.payByDate'].value))
		{
			errors = 'Please enter a valid pay by date(only integers)';
			pa.innerHTML = errors;
			return false;
		}
		return true;
    }

	/*function IsValidVendorName()
	{
		var vendorName = document.vendorForm['vendor.vendorName'].value;
		var pa = document.getElementById("errors");
		var errors = '';
		pa.innerHTML = errors;
		if ( vendorName.length == 0 )
		{
			errors = ' Enter Vendor Name';
			pa.innerHTML = errors;
			document.vendorForm['vendor.vendorName'].focus();
			return false;
		}
		for ( var counts = 0; counts < vendorName.length; counts++ )
		{
			var c = vendorName.charAt(counts);
			if (!( ( ( c >= "a" ) && ( c <= "z" ) ) || ( ( c >= "A" ) && ( c <= "Z" ) ) || ( c == "-" ) || ( c == " " ) ) )
			{
				errors = 'Enter Valid characters only for Vendor Name';
				pa.innerHTML = errors;
				return false;
			}
		}
		return true;
	}*/

	function IsValidContactName ()
	{
		var pa = document.getElementById("errors");
		var errors = '';
		pa.innerHTML = errors;
		var names = '';
		var locationCount = parseInt(document.vendorForm.vals.value)-1;
		for (var cnt = 0; cnt < locationCount; cnt ++ )
		{
			var locName = document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.contactPerson'];
			if ( checkBlankCharInBeginning(locName) == 'space' )
			{
				errors = 'Location sales person name should not start with blank space';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.contactPerson'].focus();
				return;
			}
			if ( !(commonValidation(locName)) )
			{
				errors = 'Enter Valid characters only for Location Contact Name';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.contactPerson'].focus();
				return false;
			}
		}
		return true;
	}


	function IsEmailValidated( Temp, kontact, count )
	{
		var errors = '';
		var pa = document.getElementById("errors");
		pa.innerHTML = errors;
		var locationCount = parseInt(document.vendorForm.vals.value)-1;
		var AtSym    = Temp.value.indexOf('@');
		var Period   = Temp.value.lastIndexOf('.');
		var Space    = Temp.value.indexOf(' ');
		var Length   = Temp.value.length - 2;   // Array is from 0 to length-2

		if (((AtSym < 1) ||                     // '@' cannot be in first position
		(Period <= AtSym+1) ||             // Must be atleast one valid char btwn '@' and '.'
		(Period == Length ) ||             // Must be atleast two valid char after '.'
		(Space  > 0)) && (Temp.value != ''))// No empty spaces permitted
		{
			errors = "Please enter a valid "+kontact+" email address";
			pa.innerHTML = errors;
			if ( kontact == 'sales' )
			{
				document.vendorForm['vendor.salesAddress.email'].focus();
				return false;
			}
			else
			{
				document.vendorForm['vendor.locationsList['+count+'].locationAddress.email'].focus();
				return false;
			}
		}
		return true;
	}

	function IsValidSalesAddress ()
	{
		var pa = document.getElementById("errors");
		var errors = '';
		pa.innerHTML = errors;
		//var field = '';
		/*if ( checkBlankCharInBeginning(document.vendorForm['vendor.salesAddress.email']) == 'space' )
		{
			errors = 'Sales Email address should not start with blank space';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.email'].focus();
			return;
		}*/
		if ( !IsEmailValidated(document.vendorForm['vendor.salesAddress.email'], 'sales', 0) )
		{
			return false;
		}
		/*if ( checkBlankCharInBeginning(document.vendorForm['vendor.salesAddress.phoneNumber']) == 'space' )
		{
			errors = 'Sales address phone should not start with blank space';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.phoneNumber'].focus();
			return;
		}*/
		if( !commonValidation ( document.vendorForm['vendor.salesAddress.phoneNumber'] ) )
		{
			errors = 'Please enter a valid Phone number';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.phoneNumber'].focus();
			return false;
		}
		/*if ( checkBlankCharInBeginning(document.vendorForm['vendor.salesAddress.faxNumber']) == 'space' )
		{
			errors = 'Sales address fax should not start with blank space';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.faxNumber'].focus();
			return;
		}*/
        if(!commonValidation(document.vendorForm['vendor.salesAddress.faxNumber']))
		{
			errors = 'Please enter a valid fax Number';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.faxNumber'].focus();
			return false;
		}
		if ( checkBlankCharInBeginning(document.vendorForm['vendor.salesAddress.city']) == 'space' )
		{
			errors = 'Sales address city should not start with blank space';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.city'].focus();
			return;
		}
		if(!commonValidation(document.vendorForm['vendor.salesAddress.city']))
		{
			errors = 'Please enter a valid City(only alphabets)';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.city'].focus();
			return false;
		}
		if ( checkBlankCharInBeginning(document.vendorForm['vendor.salesAddress.state']) == 'space' )
		{
			errors = 'Sales address state should not start with blank space';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.state'].focus();
			return;
		}
		if(!commonValidation(document.vendorForm['vendor.salesAddress.state']))
		{
			errors = 'Please enter a valid State(only alphabets)';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.state'].focus();
			return false;
		}
		if ( checkBlankCharInBeginning(document.vendorForm['vendor.salesAddress.country']) == 'space' )
		{
			errors = 'Sales address country should not start with blank space';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.country'].focus();
			return;
		}
		if(!commonValidation(document.vendorForm['vendor.salesAddress.country']))
		{
			errors = 'Please enter a valid Country(only alphabets)';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.country'].focus();
			return false;
		}

        /* Commented by Rohan on July 23rd 2004
		if ( !isInteger (document.vendorForm['vendor.salesAddress.zipCode'].value) )
		{
			errors = 'Please enter a valid Zip Code(only numericals)';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesAddress.zipCode'].focus();
			return false;
		}
        */
		return true;
	}


	function IsValidLocationAddress ()
	{
		var pa = document.getElementById("errors");
		var errors = '';
		pa.innerHTML = errors;
		var locationCount = parseInt(document.vendorForm.vals.value);
        for (var cnt = 0; cnt < locationCount; cnt ++ )
		{
			/*if ( checkBlankCharInBeginning(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.email']) == 'space' )
			{
				errors = 'Location address email should not start with blank space';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.email'].focus();
				return false;
			}*/

			if ( !IsEmailValidated(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.email'] , 'location', cnt ) )
			{
				return false;
			}

			/*if ( checkBlankCharInBeginning(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.phoneNumber']) == 'space' )
			{
				errors = 'Location address phone number should not start with blank space';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.phoneNumber'].focus();
				return false;
			}*/

			if(!commonValidation(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.phoneNumber']))
			{
				errors = 'Please enter a valid phone Number';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.phoneNumber'].focus();
				return false;
			}

			/*if ( checkBlankCharInBeginning(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.faxNumber']) == 'space' )
			{
				errors = 'Location address fax number should not start with blank space';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.faxNumber'].focus();
				return false;
			}*/

			if(!commonValidation(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.faxNumber']))
			{
				errors = 'Please enter a valid fax number';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.faxNumber'].focus();
				return false;
			}

			if ( checkBlankCharInBeginning(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.city']) == 'space' )
			{
				errors = 'Location address city should not start with blank space';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.city'].focus();
				return false;
			}
           if(!commonValidation(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.city']))
			{
				errors = 'Please enter a valid City(only alphabets)';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.city'].focus();
				return false;
			}

			if ( checkBlankCharInBeginning(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.state']) == 'space' )
			{
				errors = 'Location address state should not start with blank space';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.state'].focus();
				return false;
			}

			if(!commonValidation(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.state']))
			{
				//Alert ('not a valid state');
				errors = 'Please enter a valid State(only alphabets)';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.state'].focus();
				return false;
			}

			if ( checkBlankCharInBeginning(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.country']) == 'space' )
			{
				errors = 'Location address country should not start with blank space';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.country'].focus();
				return false;
			}

			if(!commonValidation(document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.country']))
			{
				//Alert ('not a valid country');
				errors = 'Please enter a valid Country(only alphabets)';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.country'].focus();
				return false;
			}

            /* Commented by Rohan on July 23rd 2004
			if ( !isInteger (document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.zipCode'].value) )
			{
				//Alert ('not a valid zip code');
				errors = 'Please enter a valid Zip Code(only numericals)';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList['+cnt+'].locationAddress.zipCode'].focus();
				return false;
			}
            */
		}
		return true;
	}


	function saveVendor(theForm,val)
	{
		var errors = '';
		var pa = document.getElementById("errors");
		pa.innerHTML = errors;

		if( document.vendorForm['vendor.salesContact'].value == "" || document.vendorForm['vendor.locationsList[0].locationAddress.contactPerson'].value == "" )
		{
			getVendorName();
		}

		if ( checkBlankCharInBeginning(document.vendorForm['vendor.vendorName']) == 'space' )
		{
			errors = 'Vendor Name should not start with blank space';
			pa.innerHTML = errors;
			return;
		}
		if ( document.vendorForm['vendor.vendorName'].value.length <= 0 )
		{
			errors = 'Vendor Name cannot be blank';
			pa.innerHTML = errors;
			document.vendorForm['vendor.vendorName'].focus();
			return;
		}
        if ( checkHasResrictedChars( document.vendorForm['vendor.vendorName'], 'Vendor Name' ) )
        {
            document.vendorForm['vendor.vendorName'].focus();
			return;
        }
		if ( !commonValidation(document.vendorForm['vendor.vendorName']) )
		{
			errors = 'Enter a valid Vendor Name';
			pa.innerHTML = errors;
			document.vendorForm['vendor.vendorName'].focus();
			return;
		}

		if ( checkBlankCharInBeginning(document.vendorForm['vendor.vendorNumber']) == 'space' )
		{
			errors = 'Vendor Number should not start with blank space';
			pa.innerHTML = errors;
			document.vendorForm['vendor.vendorNumber'].focus();
			return;
		}
		if ( document.vendorForm['vendor.vendorNumber'].value.length <= 0 )
		{
			errors = 'Vendor Number cannot be blank';
			pa.innerHTML = errors;
			document.vendorForm['vendor.vendorNumber'].focus();
			return;
		}
		if ( !commonValidation(document.vendorForm['vendor.vendorNumber']) )
		{
			errors = 'Enter a valid Vendor Number';
			pa.innerHTML = errors;
			document.vendorForm['vendor.vendorNumber'].focus();
			return;
		}
        if ( checkHasResrictedChars( document.vendorForm['vendor.vendorNumber'], 'Vendor Number' ) )
        {
            document.vendorForm['vendor.vendorNumber'].focus();
			return;
        }
        /*if(document.vendorForm['vendor.locationsList[0].locationAddress.city'].value.indexOf("'") > 0)
        {
            errors = 'Enter a valid City without single quotes';
			pa.innerHTML = errors;
            document.vendorForm['vendor.locationsList[0].locationAddress.city'].focus();
            document.vendorForm['vendor.locationsList[0].locationAddress.city'].select();
            return;
        }*/

		if ( !IsValidNetTerms(document.vendorForm['vendor.netTerms']) )
		{
			document.vendorForm['vendor.netTerms'].focus();
			return;
		}

		if ( !IsValidPayByDate() )
		{
			document.vendorForm['vendor.payByDate'].focus();
			return;
		}

		if ( checkBlankCharInBeginning(document.vendorForm['vendor.salesContact']) == 'space' )
		{
			errors = 'Sales contact name should not start with blank space';
			pa.innerHTML = errors;
			return;
		}
		if ( !commonValidation(document.vendorForm['vendor.salesContact']) )
		{
			errors = 'Enter a valid sales contact Name';
			pa.innerHTML = errors;
			document.vendorForm['vendor.salesContact'].focus();
			return;
		}
        if ( !IsValidSalesAddress ())
		{
			return;
		}

		if ( !IsValidContactName() )
		{
			return;
		}



		if ( !IsValidLocationAddress () )
		{
			return;
		}
        if ( !checkDuplicatesForAlternateVendorNames() )
        {
            return;
        }
		var locationCount = parseInt(document.vendorForm.vals.value)-1;
		// added by swadesh sahoo for checking at least one location should be checked..
		var len = document.vendorForm['vendor.locationsList[0].locationAddress.selectedLocationTypes'].length;
		//alert(len);
		var flag = true;
		var chk;
		for( chk =0;chk< len;chk++)
		{
	    if (document.vendorForm['vendor.locationsList[0].locationAddress.selectedLocationTypes'][chk].checked == true)
		{
			//alert('check for location '+chk);
			flag = false;
			break;
		}


		}

		/*if ( locationCount > 1 )
		{
			var flag = true;
			for ( var cout = 0; cout < locationCount; cout++ )
			{
				if ( document.vendorForm['vendor.locationsList['+cout+'].remove'].checked != true )
				{
					flag = false;
					break;
				}
			}
		}*/
			if ( flag )
			{
				errors = 'You should select at least one location for this vendor';
				pa.innerHTML = errors;
				document.vendorForm['vendor.locationsList[0].locationAddress.selectedLocationTypes'][0].focus();
				return;
			}


		theForm.action.value = "SaveVendor";
		document.vendorForm['vendor.vendorName'].disabled=false;
		theForm.submit();

	}
    function checkDuplicatesForAlternateVendorNames ( )
    {
        var pa = document.getElementById("errors");
		var errors = '';
		pa.innerHTML = errors;
        var form = document.forms["vendorForm"];
        var alternateVendorNamesCtrl = form.elements["vendor.alternateVendorNames"];
        if ( alternateVendorNamesCtrl.length != 'undefined' )
        {
            for( var k = 0; k < alternateVendorNamesCtrl.length; k++ )
            {
                var name  = alternateVendorNamesCtrl[k].value.trim();
                if( name != '' )
                {
                    for( var i = 0; i < k; i++ )
                    {
                        var lastName = alternateVendorNamesCtrl[i].value;
                        if( name.trim().toUpperCase() == lastName.trim().toUpperCase() )
                        {
                            errors = errors+"<li> Alternate Vendor Name '" + lastName.trim() + "' already exists please enter another name";
                            pa.innerHTML = errors;
                            alternateVendorNamesCtrl[k].focus();
                            return false;
                        }
                    }
                }
            }
        }
        return true;
    }
    function cancelAndGoBack()
	{
		document.vendorForm.action.value = "SearchVendor";
		document.vendorForm.submit();
	}

	function commonValidation( tempObj )
	{
		var obj = tempObj.value;
		for ( var counts = 0; counts < obj.length; counts++ )
		{
			var c = obj.charAt(counts);
			if ( ( c == "{" ) || ( c == "}" ) || ( c == "[" ) || ( c == "]" ) || ( c == "(" ) || ( c == ")" )
				|| ( c == "!" ) || ( c == "@" ) || ( c == "#" ) || ( c == "$" ) || ( c == "%" ) || ( c == "&" )
				|| ( c == "*" ) || ( c == "<" ) || ( c == ">" ) || ( c == "~" ) || ( c == "`" ) || ( c == "+" )
				|| ( c == "=" ) || ( c == "|" ) || ( c == "?" ) || ( c == "\\" ) || ( c == "'" ) )
			{
				return false;
			}
		}
		return true;
	}

	function checkBlankCharInBeginning( tempObj )
	{
		var obj = tempObj.value;
		if ( obj.indexOf (' ') == 0 )
		{
			return 'space';
		}
		return 'valid';
	}

	function openVendorContactPerson( type )
	{
		var vendorID = document.vendorForm['vendor.vendorId'].value;
		var contactPersonURL = '<%=chipTracContext%>/vendorContactPerson.do?action=load&vendorId=' + vendorID + '&type='+ type;

        newWindow = window.open (contactPersonURL, 'optionsPopup', 'channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=no,scrollbars=yes,width=900,height=450,resizable=yes');
	}
	
	var constantType = '<%=Constants.VENDOR_SALES_LOCATION %>'

	/*
	 * Added by kumar for displying email, phoneNumber ,Fax, CellNumber of the Contact Person when he is selected as default
	 */
	function assignContactPerson( name, email, Phone, Fax, CellNumber,type, i )
	{
        //Commented by Kumaraswamy on Oct 4th, 2004.
		//if ( type == constantType && i == 1 )
        if ( type == constantType )
		{

			document.vendorForm['vendor.salesContact'].value = name;
			document.vendorForm['vendor.salesAddress.email'].value = email;
			document.vendorForm['vendor.salesAddress.phoneNumber'].value = Phone;
			document.vendorForm['vendor.salesAddress.faxNumber'].value = Fax;
			document.vendorForm['vendor.salesAddress.cellNumber'].value = CellNumber;
		}
		else
		{   //Commented by Kumaraswamy on Oct 4th, 2004.
			//if( i == 1)
			//{
				document.vendorForm['vendor.locationsList[0].locationAddress.contactPerson'].value = name;
				document.vendorForm['vendor.locationsList[0].locationAddress.email'].value = email;
				document.vendorForm['vendor.locationsList[0].locationAddress.phoneNumber'].value = Phone;
				document.vendorForm['vendor.locationsList[0].locationAddress.faxNumber'].value = Fax;
				document.vendorForm['vendor.locationsList[0].locationAddress.cellNumber'].value = CellNumber;
			//}

		}
	}
     //*
	 //* Added by kumar for selecting vendor name as contact person if any one of the Sales Office Address fields or
	 //* Vendor Locations fields is selected and contact person is not selected.
	 //*
	function getVendorName()
	{
		var vendorName = document.vendorForm['vendor.vendorName'].value;
		var s_contact  = document.vendorForm['vendor.salesContact'].value;
		var s_email    = document.vendorForm['vendor.salesAddress.email'].value;
	    var s_phonNu   = document.vendorForm['vendor.salesAddress.phoneNumber'].value;
		var s_fax      = document.vendorForm['vendor.salesAddress.faxNumber'].value;
		var s_cellNu   = document.vendorForm['vendor.salesAddress.cellNumber'].value;
		var s_addr1    = document.vendorForm['vendor.salesAddress.address1'].value;
	    var s_addr2    = document.vendorForm['vendor.salesAddress.address2'].value;
	    var s_addr3    = document.vendorForm['vendor.salesAddress.address3'].value;
		var s_addr4    = document.vendorForm['vendor.salesAddress.address4'].value;
		var s_city     = document.vendorForm['vendor.salesAddress.city'].value;
		var s_state    = document.vendorForm['vendor.salesAddress.state'].value;
		var s_zcode    = document.vendorForm['vendor.salesAddress.zipCode'].value;
		var s_country  = document.vendorForm['vendor.salesAddress.country'].value;

		var l_contact  = document.vendorForm['vendor.locationsList[0].locationAddress.contactPerson'].value;
		var l_email    = document.vendorForm['vendor.locationsList[0].locationAddress.email'].value;
        var l_phonNu   = document.vendorForm['vendor.locationsList[0].locationAddress.phoneNumber'].value;
		var l_fax      = document.vendorForm['vendor.locationsList[0].locationAddress.faxNumber'].value;
		var l_cellNu   = document.vendorForm['vendor.locationsList[0].locationAddress.cellNumber'].value;
		var l_addr1    = document.vendorForm['vendor.locationsList[0].locationAddress.address1'].value;
		var l_addr2    = document.vendorForm['vendor.locationsList[0].locationAddress.address2'].value;
		var l_addr3    = document.vendorForm['vendor.locationsList[0].locationAddress.address3'].value;
		var l_addr4    = document.vendorForm['vendor.locationsList[0].locationAddress.address4'].value;
		var l_city     = document.vendorForm['vendor.locationsList[0].locationAddress.city'].value;
		var l_state    = document.vendorForm['vendor.locationsList[0].locationAddress.state'].value;
		var l_zcode    = document.vendorForm['vendor.locationsList[0].locationAddress.zipCode'].value;
		var l_country  = document.vendorForm['vendor.locationsList[0].locationAddress.country'].value;

		if( document.vendorForm['vendor.salesContact'].value == "" && ( s_phonNu != "" || s_email != "" || s_fax != "" || s_cellNu != "" || s_addr1 != "" || s_addr2 != "" || s_addr3 != "" || s_addr4 != "" || s_city != "" || s_state != "" || s_zcode != "" || s_country != "") )
		{
			document.vendorForm['vendor.salesContact'].value = vendorName;

		}

      	if( document.vendorForm['vendor.locationsList[0].locationAddress.contactPerson'].value == "" && (l_phonNu != "" || l_email != ""|| l_fax != "" || l_cellNu != "" || l_addr1 != "" || l_addr2 != "" || l_addr3 != "" || l_addr4 != "" || l_city != "" || l_state != "" || l_zcode != "" || l_country != "") )
		{
			document.vendorForm['vendor.locationsList[0].locationAddress.contactPerson'].value = vendorName;
		}

	}

    //added by sujan on 08th dec 2004 as to restrict the special charaters for vendor name and vendor number.
    function checkHasResrictedChars( control, controlName )
	{
		var controlValue = control.value;
		var pa = document.getElementById("errors");
		var errors = '';
		pa.innerHTML = errors;
		if ( controlValue.length == 0 )
		{
			errors = ' Enter ' + controlName;
			pa.innerHTML = errors;
			control.focus();
			return true;
		}
		for ( var count = 0; count < controlValue.length; count++ )
		{
			var chr = controlValue.charAt(count);
            if ( count == 0 || count == (controlValue.length - 1) )
            {
                if ( chr == '_' || chr == '-' || chr == '/' || chr == ';' || chr == ':' || chr == '^' ) //restricting characters _ , - / at the beginning
                {
                    errors = 'Enter Valid characters only for ' + controlName;
				    pa.innerHTML = errors;
                    return true;
                }

            }
            else
            {
			    if ( chr == ';' || chr == ':' || chr == '^' )
			    {
				    errors = 'Enter Valid characters only for ' + controlName;
				    pa.innerHTML = errors;
				    return true;
			    }
		    }
        }
		return false;
	}
function selectVendorShipperRelation()
{
    var vendorId   = document.vendorForm['vendor.vendorId'].value;
    var vendorName = document.vendorForm['vendor.vendorName'].value;

    var LeftPos=(screen.width)?(screen.width-500)/2:100;
    var TopPos=(screen.height)?(screen.height-450)/2:100;
    newWindow = window.open ('<%=chipTracContext%>/vendorShipperRelationship.do?action=vendorRelationships&vendorId='+vendorId+'&vendorName='+vendorName,'customerSalespersons','channelmode=no,directories=no,toolbar=no,menubar=no,personalbar=no,status=yes,scrollbars=yes,width=540,height=500,resizable=yes,Left= '+LeftPos+',top='+TopPos );
    if(!newWindow.opener) {newWindow.opener = window}
    newWindow.focus();
}

function addOptionToSelect(aName, aValue)
{
    var shipperObj = document.vendorForm['vendor.shipperId'];

    addOption(shipperObj, aName + "", aValue, shipperObj.options.length);

    for( var i=0 ; i < shipperObj.options.length ; i++ )
    {
        if(shipperObj.options[i].value == document.vendorForm.hiddenShipperId.value)
        {
            shipperObj.options[i].selected = true;
        }
    }
}

function addOption(aSelect, aName, aValue, anIndex)
{
   var aOption = new Option(aName, aValue)
   aSelect.options[anIndex] = aOption;
}

function deleteAllOptions()
{

    var shipperObj = document.vendorForm['vendor.shipperId'];
    var optionValue1 = document.vendorForm.hiddenShipperId.value;

    if( typeof shipperObj !='undefined' )
    {
        for( var j = shipperObj.options.length ; j >= 0 ; j-- )
        {
             shipperObj.options[j] = null;
        }
    }
}
function setHiddenShipperId()
{
    document.vendorForm.hiddenShipperId.value = document.vendorForm['vendor.shipperId'].value;
}
function addAlternateVendorNameField( )
{
    var table = document.getElementById("alternateVendorNameTable");
    var newRow = table.insertRow();
    var td = newRow.insertCell();
    td.innerHTML = '<input type=text name="vendor.alternateVendorNames" class=txfield size="25" maxlength="100" />';
}

</SCRIPT>

<script src="<%=chipTracContext%>/jsp/includes/scripts/functions.js"></script>
<script src="<%=chipTracContext%>/jsp/includes/scripts/validations.js">
</script>
<!-- Top Header Start-->


<%@ include file="/jsp/includes/header.jsp" %>
<!-- Top Header End-->

<TABLE cellSpacing=0 cellPadding=0 width="100%" border=0>
  <TBODY>
  <TR>
	<TD width='180' valign='top' background='<%=chipTracContext%>/jsp/includes/images/left_red_bg.gif'>

<!-- Side Navigation start -->


<%@ include file="/jsp/operations/operations_menu.jsp" %>

	</TD>
<!-- end of the side navigations -->

<TD bgcolor="#ffffff">
<IMG height=9 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=8></TD>
<TD bgcolor="#ffffff"><IMG height=480 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=2></TD>
<TD valign="top" width="100%">

<IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/clear.gif" width=500 border=0>
<BR>
<!-- from here your body starts -->


<center><span class="NArialW">Vendor Setup</span></center>
<img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20>

<html:form  name="vendorForm" type="com.scalar.chiptrack.operations.vendor.forms.VendorForm" action="/vendor.do" >

<nested:nest property="vendor">
<nested:hidden property="vendorId" />
<table border="0" width="92%" align=right>
<% if ( !user.isActionAllowed ( Functionality.VENDOR_DETAILS, User.USER_ACTION_MODIFY  )  ) { %> 
<tr><td colspan='5'> 
<font class='NArialS'><font color='blue'><b><%=Constants.NO_MODIFY_RIGHTS %></b>
</font></font></td></tr>
<% } %>
 <tr><td colspan='5' class="NArialL">
    <FONT color='FF0000'>
    <logic:present name="errorMsg">
        <bean:write name="errorMsg" />
    </logic:present>
    </FONT>
    <chiptrack:errors  styleClass="NArialL" />
 </td></tr>
<tr><td colspan='5' align="left" class='NArialL'><FONT id="errors" size="-2" color='FF0000'></FONT></TD></TR>
 <tr>
   <td width="15%">
    <font class="NArialL" >Vendor Name :</font><font color="RED" size="1"><B>*</B></font>
	<td width= "20%"><font class="NArialL" >
        <logic:equal name="vendorForm" property="action" value="CreateVendor">
            <nested:text property="vendorName" size="23" styleClass="txfield" maxlength="50" />
        </logic:equal>
        <logic:notEqual name="vendorForm" property="action" value="CreateVendor">
            <nested:text property="vendorName" size="23" styleClass="txfield" disabled="true"/>        
        </logic:notEqual>
     </font>
   </td>
   <td width="8%">&nbsp;</td>
    <td width="24%"><font class="NArialL" >Vendor Code</font></td>
    <td width="25%">
	    <nested:text property="vendorCode" size="10" maxlength="1" styleClass="txfield"/>
	</td>  
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Vendor # :</font><font color="RED" size="1"><B>*</B></font></td>
    <td width="20%"><font class="NArialL" >
        <logic:equal name="vendorForm" property="action" value="CreateVendor">
            <nested:text property="vendorNumber" size="23" styleClass="txfield" maxlength="50" />
        </logic:equal>
        <logic:notEqual name="vendorForm" property="action" value="CreateVendor">
            <nested:text property="vendorNumber" size="23" styleClass="txfield" disabled="true"/>       
        </logic:notEqual>
	
    </td>
    <td width="8%">&nbsp;</td>
    <td width="24%"><font class="NArialL" >Net Terms :</font></td>
    <td width="25%">
	<!--Bhaskar changed and commented these 2 lines of code on 27 Nov 2003-->
	<nested:text property="netTerms" size="23" styleClass="txfield"/>
	<!--nested:text property="netTerms" size="23" styleClass="txfield"/ onkeyup="javascript:IsValidNetTerms(this);"/-->
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Po Frequency :</font></td>
    <td width="20%"><font class="NArialL">
      <nested:select property="poFrequency" styleClass="txfield">
        <html:options collection="poFrequencies" property="value"
                   labelProperty="label"/>
      </nested:select>
     </td>
    <td width="8%">&nbsp;</td>
    <td width="20%"><font class="NArialL" >Pay By Date :</font></td>
    <td width="32%">
	<!--Bhaskar changed and commented these 2 lines of code on 27 Nov 2003-->
	<nested:text property="payByDate" size="23" styleClass="txfield" />
	<!--nested:text property="payByDate" size="23" styleClass="txfield" onchange="javascript:IsValidPayByDate(this);"/-->
    </td>
  </tr>
  <tr>
    <td width="20%"><font class="NArialL" >Shipper :</font></td>
    <td width="20%"><font class="NArialL">
      <nested:select property="shipperId" styleClass="txfield" onchange="javascript:setHiddenShipperId()">
        <html:option value="0">----select----</html:option>
        <html:options collection="shippers" property="value" labelProperty="label"/>
      </nested:select>
      <input type="hidden" name="hiddenShipperId" value="<nested:write property="shipperId"/>" />
     </td>
    <td width="8%">&nbsp;</td>
    <td width="20%"></td>
    <td width="32%"></td>
  </tr>
  <tr>
    <td width="20%" colspan="5"><font class="NArialL">Please <a styleClass="leftsection" href="javascript:selectVendorShipperRelation()" onmouseover="window.status='Click to select Vendor/Shipper Relationship';return true" onmouseout="window.status='';return true">
        Click here</a>&nbsp;to Add Vendor/Shipper Relationships
        </font>
    </td>
  </tr>
  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>
  <tr>
      <td colspan=3 class="NArialL" valign="top">Comments :<br>
	    <nested:textarea property="comments" rows="4" cols="70" styleClass="txfield" />
      </td>
      <td class="NArialL" valign="top">
          Alternate Vendor Names:
      </td>
      <td valign="top">
          <table id="alternateVendorNameTable" cellSpacing=0 cellPadding=0>              
              <nested:present property="alternateVendorNames">
                  <nested:size id="size" property="alternateVendorNames"/>
                  <logic:greaterThan value="0" name="size">
                      <nested:iterate property="alternateVendorNames" id="alternateVendorName" indexId="idx" type="java.lang.String">
                          <tr>
                              <td nowrap><input type="text" name="vendor.alternateVendorNames" size="25" maxlength="100" class="txfield" value="<%= new String( alternateVendorName.getBytes("ISO-8859-1"), "UTF-8")%>">
                                  <logic:equal value="0" name="idx">
                                       <a href="javascript:addAlternateVendorNameField();" onMouseOver="window.status='Click to Add New Alternate Vendor Name';return true" onMouseOut="window.status='';return true"title='Click here to Add New Alternate Vendor Name'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align="middle"></a>
                                  </logic:equal>
                              </td>
                          </tr>
                      </nested:iterate>
                  </logic:greaterThan>
                  <logic:lessEqual value="0" name="size">
                      <tr>
                          <td nowrap><input type="text" name="vendor.alternateVendorNames" size="25" maxlength="100" class="txfield" value="">
                                   <a href="javascript:addAlternateVendorNameField();" onMouseOver="window.status='Click to Add New Alternate Vendor Name';return true" onMouseOut="window.status='';return true"title='Click here to Add New Alternate Vendor Name'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align="middle"></a>
                          </td>
                      </tr>
                  </logic:lessEqual>
              </nested:present>
              <nested:notPresent property="alternateVendorNames">
                  <tr>
                      <td nowrap><input type="text" name="vendor.alternateVendorNames" size="25" maxlength="100" class="txfield" value="">
                               <a href="javascript:addAlternateVendorNameField();" onMouseOver="window.status='Click to Add New Alternate Vendor Name';return true" onMouseOut="window.status='';return true"title='Click here to Add New Alternate Vendor Name'><img border=0 src='<%=chipTracContext%>/jsp/includes/images/add.jpg' height='15' width='20' align="middle"></a>
                      </td>
                  </tr>
              </nested:notPresent>
          </table>
      </td>
  </tr>
  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=10></td></tr>

  <tr>
    <td width="20%" height="23" bgcolor="#DEE1E2" colspan=5><font class="NArialL" >Sales Office Address:</font></td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Contact Person :</font></td>
    <td width="20%" height="23">
	<nested:text property="salesContact" size="23" styleClass="txfield" maxlength="50" />
    </td>
    <td width="8%" height="23" class="NArialL"><%-- <a href="javascript:openVendorContactPerson('<%=Constants.VENDOR_SALES_LOCATION %>')">Add/Modify</a></font> --%></td>
    <td width="20%" height="23"><font class="NArialL" >Email :</font></td>
    <td width="32%" height="23">
    <nested:nest property="salesAddress">
		<!--Bhaskar changed and commented these 2 lines of code on 27 Nov 2003-->
		<nested:text property="email" size="23" styleClass="txfield" maxlength="50" />
       	<!--nested:text property="email" size="23" styleClass="txfield" onchange="javascript:IsEmailValid(this);"/-->
    </td>
  </tr>

  <tr>
  <td width="30%" height="23"><font class="NArialL" ><a href="javascript:openVendorContactPerson('<%=Constants.VENDOR_SALES_LOCATION %>')" onMouseover="window.status='Click to Add/Modify Vendor Contact Person';return true" onMouseout="window.status='';return true">
  Add/Modify Contact Person</a></font></td>
  </tr>

  <tr>
    <td width="20%" height="23"><font class="NArialL" >Phone :</font></td>
    <td width="20%" height="23">
	<nested:text property="phoneNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/>
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Fax :</font></td>
    <td width="32%" height="23">
  	<nested:text property="faxNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/>
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Cell Number :</font></td>
    <td width="20%" height="23">
	<nested:text property="cellNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/>
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >&nbsp;</font></td>
    <td width="32%" height="23">
  	&nbsp;
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Address 1 :</font></td>
    <td width="20%" height="23">
  	<nested:text property="address1" size="23" styleClass="txfield" maxlength="50" />
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Address 2 :</font></td>
    <td width="32%" height="23">
  	<nested:text property="address2" size="23" styleClass="txfield" maxlength="50" />
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Address 3 :</font></td>
    <td width="20%" height="23">
  	<nested:text property="address3" size="23" styleClass="txfield" maxlength="50" />
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Address 4 :</font></td>
    <td width="32%" height="23">
  	<nested:text property="address4" size="23" styleClass="txfield" maxlength="50" />
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >City :</font></td>
    <td width="20%" height="23">
  	<nested:text property="city" size="23" styleClass="txfield" maxlength="50" />
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >State :</font></td>
    <td width="32%" height="23">
	<!--Bhaskar changed and commented these 2 lines of code on 28 Nov 2003-->
  	<nested:text property="state" size="23" styleClass="txfield"  maxlength="50" />
  	<!--nested:text property="state" size="23" styleClass="txfield"  maxlength="50" onchange="javascript:isValidState(this);"/-->
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Zip :</font></td>
    <td width="20%" height="23">
  	<nested:text property="zipCode" size="23" styleClass="txfield" /><!--onchange="javascript:isValidZipCode(this);" /-->
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Country :</font></td>
    <td width="32%" height="23">
	<!--Bhaskar changed and commented these 2 lines of code on 28 Nov 2003-->
  	<nested:text property="country" size="23" styleClass="txfield" maxlength="50" />
  	<!--nested:text property="country" size="23" styleClass="txfield" maxlength="50" onchange="javascript:isValidCountry(this);"/-->
    </td>
  </tr>
  
  </nested:nest>
  <% int i=1; %>  
  <nested:iterate property="locationsList">
  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
  <tr>
    <td height="23" colspan=5 bgcolor="#DEE1E2"><font class="NArialL" >Vendor Locations <!-- - < % = i++ %> --> :</font>
    &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
    <!--nested:checkbox property="remove" value="true" /> <FONT class='NArialL'>Remove </FONT>-->
    </td>
  </tr>
  <tr>
  <nested:nest property="locationAddress">
    <td width="20%" height="23"><font class="NArialL" >Contact Person :</font></td>
    <td width="20%" height="23">
      	<nested:text property="contactPerson" styleClass="txfield" size="23" maxlength="50" />
    </td>
	<td width="8%" height="23"><!-- <font class="NArialL"><a href="javascript:openVendorContactPerson('<%=Constants.VENDOR_SHIPPING_LOCATION %>')">Add/Modify</a></font> --></td>
    
    <td width="20%" height="23"><font class="NArialL" >Email :</font></td>
    <td width="32%" height="23">
		<!--Bhaskar changed and commented these 2 lines of code on 28 Nov 2003-->
    	<nested:text property="email" styleClass="txfield" size="23" />
		<!--nested:text property="email" styleClass="txfield" size="23" onchange="javascript:IsEmailValid(this);"/-->
    </td>
  </tr>
  <tr>
  <td width="30%" height="23"><font class="NArialL" ><a href="javascript:openVendorContactPerson('<%=Constants.VENDOR_SHIPPING_LOCATION %>')"onMouseover="window.status='Click to Add/Modify Vendor Contact Person';return true" onMouseout="window.status='';return true">
  Add/Modify Contact Person</a></font></td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Phone :</font></td>
    <td width="20%" height="23">
	<nested:text property="phoneNumber" styleClass="txfield" size="23" onkeypress='validatePhoneNumber(this)'/>
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Fax :</font></td>
    <td width="32%" height="23">
	<nested:text property="faxNumber" styleClass="txfield" size="23" onkeypress='validatePhoneNumber(this)'/>
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Cell Number :</font></td>
    <td width="20%" height="23">
	<nested:text property="cellNumber" size="23" styleClass="txfield" onkeypress='validatePhoneNumber(this)'/>
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >&nbsp;</font></td>
    <td width="32%" height="23">
  	&nbsp;
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Address 1 :</font></td>
    <td width="20%" height="23">
	<nested:text property="address1" styleClass="txfield" size="23" maxlength="50" />
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Address 2 :</font></td>
    <td width="32%" height="23">
	<nested:text property="address2" styleClass="txfield" size="23" maxlength="50" />
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Address 3 :</font></td>
    <td width="20%" height="23">
	<nested:text property="address3" styleClass="txfield" size="23" maxlength="50" />
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Address 4 :</font></td>
    <td width="32%" height="23">
	<nested:text property="address4" styleClass="txfield" size="23" maxlength="50" />
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >City :</font></td>
    <td width="20%" height="23">
	<nested:text property="city" styleClass="txfield" size="23" maxlength="50" />
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >State :</font></td>
    <td width="32%" height="23">
	<!--Bhaskar changed and commented these 2 lines of code on 28 Nov 2003-->
	<nested:text property="state" styleClass="txfield" size="23" maxlength="50" />
	<!--nested:text property="state" styleClass="txfield" size="23" maxlength="50" onchange="javascript:isValidState(this);"/-->
    </td>
  </tr>
  <tr>
    <td width="20%" height="23"><font class="NArialL" >Zip :</font></td>
    <td width="20%" height="23">
	<!--Bhaskar changed and commented these 2 lines of code on 28 Nov 2003-->
	<nested:text property="zipCode" styleClass="txfield" size="23" />
    </td>
    <td width="8%" height="23"></td>
    <td width="20%" height="23"><font class="NArialL" >Country :</font></td>
    <td width="32%" height="23">
		<!--Bhaskar changed and commented these 2 lines of code on 28 Nov 2003-->
    	<nested:text property="country" styleClass="txfield" size="23" maxlength="50" />
    	<!--nested:text property="country" styleClass="txfield" size="23" maxlength="50" onchange="javascript:isValidCountry(this);"/-->
    </td>
  </tr>
  <tr>
    <td colspan=5>
  	 <logic:iterate name="vendorForm" id="locationTypes" property="locationTypes">
  	 	<font class="NArialL">
  	 	<nested:multibox property="selectedLocationTypes" styleClass="txFiled">
  	 		<bean:write name="locationTypes" />
  	 	</nested:multibox>
  	 	<bean:write name="locationTypes" />
  	 	</font>
  	 </logic:iterate>
     </td>
  </tr>
    </nested:nest>

  </nested:iterate> 
  <input type="hidden" name="vals" value="<%=i%>">

<!--  <tr> <td colspan=5><nested:submit property="addOfficeLocation">Add Location</nested:submit></td></tr>-->
 
  <tr><td colspan=4>
  </td><td>&nbsp;</td></tr>  
  <tr><td colspan=5><img src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" height=20></td></tr>
  <tr><td colspan=5 align=center>
        <!-- html:image will submit the page twice as it once with submit and another with onclick  -->
		<!--Bhaskar commented the ordinary href below and replaced it with a restricted link on 10 oct 2003-->
     	 <!--a href="javascript:saveVendor(document.vendorForm,'< %=i-1%>');"> <img border="0" src="< %=chipTracContext%>/jsp/includes/images/save.gif"/></a-->
		
		<!-- <% String defaltContatPerson = "javascript:document.vendorForm.getVendorName()";%>href='<%=defaltContatPerson%>' -->
		<% String url = "javascript:saveVendor(document.vendorForm,1)";%>

		 <chiptrack:restrictedLink functionality='<%=Functionality.VENDOR_DETAILS%>' action='<%=User.USER_ACTION_MODIFY%>' href='<%=url%>'>
		 <!--chiptrack:restrictedLink functionality='< %=Functionality.VENDOR_DETAILS%>' action='< %=User.USER_ACTION_MODIFY%>' href="javascript:saveVendor(document.vendorForm,'<%=i%>');" onmouseover="window.status='Click here to save or modify Vendor details';return true" onmouseout="window.status='';return true"-->
		 <img border="0" src="<%=chipTracContext%>/jsp/includes/images/save.gif" width="53" height="17" onMouseover="window.status='Click to Save Vendor Details';return true" onMouseout="window.status='';return true" title="Click here to Save Vendor details"></chiptrack:restrictedLink>
     	  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
	  <a href="javascript:cancelAndGoBack();"><img border="0" src="<%=chipTracContext%>/jsp/includes/images/cancel.gif" width="53" height="17"onMouseover="window.status='Click to Go back to search';return true" onMouseout="window.status='';return true" title="Click here to Reset Vendor details"></a>
  </td></tr>
</table>
<input type="hidden" name="counter"   value="2">
<input type="hidden" name="action" value="">

</nested:nest>

</html:form>


<!-- till here -->
<BR><BR><BR></TD>
<TD bgcolor="#ffffff"><IMG height=1 src="<%=chipTracContext%>/jsp/includes/images/spacer.gif" width=1></TD>
</TR>
</TABLE>

<!-- Footer starts here -->

<%@ include file="/jsp/includes/footer.jsp" %>

<!-- footer end here -->

</BODY>
</HTML>